<?php
/***
 *    built in test case class supplied for 
 *    the configed test case instance.
 */

class Test_Case_Interface_BuiltIn extends Test_Case_Interface{
    private $params = null;
    private $asserts = null;
    function __construct($label,$request_str,$params,$asserts){
        $this->label = $label;
        $this->http_str = $request_str;
        $this->params = $params;
        $this->asserts = $asserts;
        parent::__construct();
    }

    function testBuiltIn(){
        $resource = $this->execute($this->getUrl($this->params));
        foreach($this->asserts as $method => $expectations){
            foreach($expectations as $expectation){
                switch($method){
                    case "contains" :
                        $this->assertContains($resource,$expectation);
                        break;
                    case "notContains" :
                        $this->assertNotContains($resource,$expectation);
                        break;
                    case "equal" :
                        $this->assertEqual($resource,$expectation);
                        break;
                    default :
                        break;
                }
            }
        }
        unset($resource);
    }

    function assertContains($value,$expect){
        return $this->assert(new Expectation_Contains($value),$expect);
    }
    function assertNotContains($value,$expect){
        return $this->assert(new Expectation_NotContains($value),$expect);
    }
    function assertEqual($value,$expect){
        return $this->assert(new Expectation_Equal($value),$expect);
    }
    function getLabel(){
        return $this->label ? $this->label : "builtIn test case name";
    }

}


?>
